<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Models\Shop\Product, App\Models\Shop\ProductCategory as Category;
class ProductController extends Controller
{
    function show($id)
    {
        $product = Product::find($id);
        //return $product;exit;
        return view('home.product')->with('product',$product);
    }
    function category()
    {
        //return 123;
        $categories = Category::get_categories();
        //return $categories;
        return view('home.category')->with('categories', $categories);
    }
    function li($id)
    {
        //return 123;
        //return $id;

        //return $category;
        $products = Product::where('category_id',$id)->get();
        //return $products;
        return view('home.list')->with('products',$products);
    }
    function search()
    {
        $products = Product::where('is_recommend', true)
            ->orderBy('is_top', "desc")
            ->orderBy('created_at')
            ->get();
        return view('home.search')->with('products', $products);
    }

}
